//
//  YGWebViewViewController.m
//  yuanshangyiliao
//
//  Created by icholab on 2021/3/23.
//

#import "YGWebViewViewController.h"
#import <WebKit/WebKit.h>
@interface YGWebViewViewController ()
@property (nonatomic, strong) UIWebView *webView;

@end

@implementation YGWebViewViewController

- (void)viewDidLoad {
    [super viewDidLoad];
//    [self.view addSubview:self.webView];
//    [self.webView l]
    // Do any additional setup after loading the view.
}

- (void)loadContent:(NSString *)content{
//    content = @"<div>asds</div>";

    [self.webView loadHTMLString:content baseURL:nil];
//    [self.webView loadHTMLString:@"<p>这是一个段落</p>" baseURL:nil];

}

- (void)webViewDidFinishLoad:(UIWebView *)webView {
    //加载完成后获取WebView实际高度
    CGFloat webViewHeight = [[webView stringByEvaluatingJavaScriptFromString:@"document.body.scrollHeight"] floatValue];
  
}

- (UIWebView *)webView{
    if (!_webView) {
        _webView = [[UIWebView alloc] initWithFrame:self.view.bounds];
        _webView.delegate = self;
        [self.view addSubview:_webView];
    }
    return _webView;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
